package view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JWindow;

import model.Territory;

public class Explosion extends JWindow {

	/**
	 * 
	 */
	//private static final long serialVersionUID = 1L;
	private Territory one;
	private Territory two;
	/**
	 * JWindow that animates through a explosion sprite sheet
	 * @param x
	 * @param y
	 */
	public Explosion(Territory x, Territory y){
		if(!RiskFrame.getAnimateOn()){
			this.dispose();
		}
		one = x;
		two = y;
		this.setVisible(false);
		//this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setMinimumSize(new Dimension(200,200));
		//this.setTitle("KA-BOOM!!!");
		this.setLocationRelativeTo(null);
		
		
//		JLabel tOne = new JLabel(one.getTerritoryName());
//		this.add(tOne, BorderLayout.NORTH);
//		JLabel tTwo = new JLabel(two.getTerritoryName());
//		this.add(tTwo, BorderLayout.SOUTH);
		
		JLabel image = new JLabel(new ImageIcon("images/explosion.gif"));
		this.add(image, BorderLayout.CENTER);
		
		this.setVisible(true);
		this.addMouseListener(new ClickMouseListener());
//		try {
//			Thread.sleep(1000);
//			
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		setVisible(false);
//		dispose();
	}
	private class ClickMouseListener implements MouseListener {

		@Override
		public void mouseClicked(MouseEvent arg0) {
			setVisible(false);
			dispose();
		}

		@Override
		public void mouseEntered(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseExited(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mousePressed(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}
		
	}
	
	
}
